<template>
    <div id="app">
        <!-- 登录后台时的登录页面是个特殊的页面，要求页面上除开登录框之外不允许拥有其他组件 -->
        <top v-if="!isLoginPage && showContent" />
        <router-view v-if="showContent" style="min-height: 500px;" />
        <bottom v-if="!isLoginPage && showContent" />
    </div>
</template>

<script>
    import top from "./components/include/top"
    import bottom from "./components/include/bottom"

    export default {
        name: "App",
        components: { top, bottom },
        data() {
            return {
                showContent: false
            }
        },
        async created() {
            if(this.$common.getFields() == null || this.$common.getLinks() == null) {
                let res1 = await this.$http.get("/field");
                this.$common.setFields(res1.data.fields);
                let res2 = await this.$http.get("/link");
                let links = res2.data.list;
                this.$common.setLinks(links);
            }
            this.showContent = true;
        },
        methods: { },
        computed: {
            // 判断当前页面是不是登录页
            isLoginPage(){
                return this.$route.path.startsWith("/login.html");
            },
        }
    }
</script>

<style scoped>
</style>
